$s = 'Posted On April 6th By Some Dude'; echo strstr($s, 'By', true); // Posted On April 6th
$variable = substr($variable, 0, strpos($variable, "By"));